import java.util.Arrays;
import java.util.Scanner;

import static java.time.Year.isLeap;

public class 日期问题 {
    static int[] isLeapYear = {0,31,29,31,30,31,30,31,31,30,31,30,31};
    static int[] noLeapYear = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    static String[] s1 = new String[4];
    static int f = 0;
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] str = s.nextLine().split("/") ;
        int a = Integer.parseInt(str[0]);
        int b = Integer.parseInt(str[2]);
        int c = Integer.parseInt(str[1]);
        if(a>b) {
            if(a>c){
                isDay(str[2],str[1],str[0]);
                isDay(str[2],str[0],str[1]);
            }
            else {
                isDay(str[2],str[0],str[1]);
                isDay(str[2],str[1],str[0]);
            }
            isDay(str[0],str[1],str[2]);
        }else {
            isDay(str[0],str[1],str[2]);
            if(a>c) {
                isDay(str[2], str[1], str[0]);
                isDay(str[2],str[0],str[1]);
            }
            else {
                isDay(str[2],str[0],str[1]);
                isDay(str[2], str[1], str[0]);
            }
        }

        for (int i = 0; i < f; i++) {
            for (int j = i+1; j < f; j++) {
                if(s1[i].equals(s1[j])) s1[j] = "0";
            }
            //System.out.println(s1[i]);
        }
        for (int i = 0; i < f; i++) {
        if(s1[i].equals("0")==false) System.out.println(s1[i]);
        }

    }
    private static void isDay(String year,String mouth,String day) {
            int y1 = Integer.parseInt("19"+year);
            int y2 = Integer.parseInt("20"+year);
            int m = Integer.parseInt(mouth);
            int d = Integer.parseInt(day);
            if(y1>=1960 && y1<= 2059 && d >0 && m<=12) {
                if(isLeap(y1) && d<=isLeapYear[m]) {
                    s1[f++] = y1+"-"+mouth+"-"+day;
                }else
                    if(d<=noLeapYear[m] ) s1[f++] = y1+"-"+mouth+"-"+day;
            }
            if(y2>=1960 && y2<= 2059 && m<=12) {
                if(isLeap(y2) && d<=isLeapYear[m] &&d >0) {
                    s1[f++] = y2+"-"+mouth+"-"+day;
                }else
                if(d<=noLeapYear[m] &&d >0) s1[f++] = y2+"-"+mouth+"-"+day;
            }
    }
    private static boolean isLeap(int year) {
        if((year%100!=0&&year%4==0) || year%400==0 ) return true;
        return false;
    }

}
